cmake_minimum_required(VERSION 3.15)
project(nosal-demo-app VERSION 1.0.0 LANGUAGES C CXX)

# Threads using pthread
set(THREADS_PREFER_PTHREAD_FLAG ON)
#find_package(Threads REQUIRED)

# Load and run CMake code from a file or module
include(FindPkgConfig)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(NOSAL/nosal)
include(NOSAL/toolchain_qnx700_aarch64)

# Enable tests
if(NOSAL_ENABLE_TESTS)
    message(STATUS "PROJECT MESSAGE: Demo Application tests are enabled")
    enable_testing()
endif()

# Look for required packages
find_package(nosal-core REQUIRED)
find_package(nosal-log REQUIRED)
find_package(nosal-exec-execution-client REQUIRED)

# Set global variabels
set(NOSAL_CMAKE_INSTALL_BINTESTDIR ${APD_CMAKE_INSTALL_BINTESTDIR})

#add_subdirectory(src)


add_executable(demo-process
    ./src/demo_process.cpp
)

target_link_libraries(demo-process
PRIVATE
    nosal::core
    nosal::log
    nosal::exec_execution_client
)


# Set these variables (like in the yocto recipe) to build the application as a specific process on a specific machine
if(NOT TARGET_MACHINE)
   set(TARGET_MACHINE "Sa8155Machine")
endif()
if(NOT APP_NAME)
        set(APP_NAME "demo-process")
endif()
if(NOT PROC_NAME)
        set(PROC_NAME "demo-process")
endif()

nosal_install_app_executable(${PROJECT_NAME} ${APP_NAME})
nosal_install_app_execution_manifest(${PROJECT_NAME} ${PROJECT_SOURCE_DIR}/files/manifest.json)

nosal_install_app_file(${PROJECT_NAME} data ${PROJECT_SOURCE_DIR}/files/data.json)
